<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
    String path=request.getContextPath();
    %>
<jsp:include page="/manage/inc/header.jsp"></jsp:include>
   <jsp:include page="/manage/inc/menu.jsp"></jsp:include>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index.jsp">首页</a><span class="crumb-step">&gt;</span><a class="crumb-name" href="<%=path%>/manage/NewsServlet?action=init">新闻管理</a><span class="crumb-step">&gt;</span><span>新增作品</span></div>
        </div>
        <div class="result-wrap">
            <div class="result-content">
                <form action="<%=path %>/manage/NewsServlet?action=insert" method="post" id="myform" name="myform" enctype="multipart/form-data">
                    <table class="insert-tab" width="100%">
                        <tbody>
                        <tr>
                                <th><i class="require-red">*</i>标题：</th>
                                <td><input name="title" id="title" type="text"><span id="titleSpan"></span></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>简介：</th>
                                <td><input name="intr" id="intr" type="text"><span id="intrSpan"></span></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>图片：</th>
                                <td>
                                
                                <img id="pici" src="<%=request.getContextPath()%>/static/images/plus.jpg"
                 				 class="am-img-responsive" style="width: 100px;height: 100px;" alt="" name="pica">    
                <input id="pic" hidden="none" type="file" name="jpg" class="inputfile" onchange="reads(this)">
                                
                                <span id="jpgSpan"></span></td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>内容：</th>
                                <td><textarea name="content" class="content" id="content" cols="80" style="width: 40%;" rows="10"></textarea><span id="contentSpan"></span></td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" id="insertButton" value="提交" type="button">
                                    <input class="btn btn6" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </form>
            </div>
        </div>

    </div>
    <!--/main-->
</div>
   <jsp:include page="/manage/inc/footer.jsp"></jsp:include>
   <script>
   
   $(function() {
	    $("#pici").click(function() {
	      $("#pic").click();
	    });
  })
  function reads(obj) {
    var file = obj.files[0];
    var reader = new FileReader();
    reader.readAsDataURL(file);
    reader.onload = function(ev) {
      $("#pici").attr("src",
          ev.target.result);
    }
  }
   
   
   $(function(){
	   
	   
	   $("#insertButton").click(function(){
		   if($("#pic").val().length==0){
			   $("#jpgSpan").html("照片不能为空");
			   return false;
		   }else{
			   $("#jpgSpan").html("");
		   }
		   if($(".content").val().length<6){
			   $("#contentSpan").html("内容不呢少于六个字");
			   return false;
		   }else{
			   $("#contentSpan").html("");
		   }
		   if($("#title").val().length==0){
			   $("#titleSpan").html("标题不能为空");
			   return false;
		   }else{
			   $("#titleSpan").html("");
		   }
		   if($("#intr").val().length==0){
			   $("#intrSpan").html("简介不能为空");
			   return false;
		   }else{
			   $("#intrSpan").html("");
		   }
		   $("#myform").submit();
	   })
   })
   </script>